const { debug } = require('webpack');
const axios = require('../utils/request');

const baidu = 'https://api.map.baidu.com';
const AK = 'zmExB7xtC6mkUNcPqcGgguzRfncY2pnA'; // 服务的ak

const urlMap = {
  driving: '/directionlite/v1/driving', // 获取驾车路线
};

module.exports = (router) => {
  // 驾车路线图-两点之间的
  router.get(urlMap.driving, async (ctx) => {
    // console.log('请求参数', ctx.query);
    const data = await axios.get(baidu + urlMap.driving, { params: { ...ctx.query, ak: AK } });
    // console.log('请求接口', data);
    return (ctx.body = data);
  });
};
